package cn.codecrab.ai.langchain4j.tools;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.springframework.stereotype.Component;

/**
 * @author 王刚
 * @since 2025年05月10日 17:34
 */
@Component
public class CalculatorTools {

    @Tool(name = "加法", value = "将两个数相加")
    public double sum(@P(value = "加数1") double a, @P(value = "加数2") double b) {
        System.out.println("调用了sum");
        return a + b;
    }

    @Tool
    public double subtract(double a, double b) {
        System.out.println("调用了subtract");
        return a - b;
    }

    @Tool
    public double multiply(double a, double b) {
        System.out.println("调用了multiply");
        return a * b;
    }

    @Tool
    public double divide(double a, double b) {
        System.out.println("调用了divide");
        return a / b;
    }

    @Tool
    public double squareRoot(double x) {
        System.out.println("调用了squareRoot");
        return Math.sqrt(x);
    }

}
